<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="./../layui/css/layui.css" media="all">
    <script src="./../layui/layui.js"></script>
    <script src="./../js/jquery-1.8.3.min.js"></script>
    <script src="./../js/env.js"></script>
    <title>充值记录</title>
    <style>

    </style>
</head>
<fieldset class="layui-elem-field layui-field-title">
    <legend>充值记录</legend>
</fieldset>
<div class="demoTable"  >
    <button type="button" class="layui-btn" style="margin-left: 10px;margin-bottom: 10px" onclick="javascript :history.back(-1)">返回</button>
</div>
<form method="get" action="" class="layui-form">

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"> 手机号</label>
            <div class="layui-input-inline">
                <input id="tel" autocomplete="off" class="layui-input" type="text">
            </div>
        </div>
        <button class="layui-btn" onclick="sech()" data-method="offset" type="button">搜索</button>
        <button type="reset" onclick="chong()" data-method="offset" class="layui-btn">重置</button>
    </div>

</form>
<body>
<table id="demo" lay-filter="test"></table>
</body>

</html>
<script>

    if (layui.sessionData('user').userInfo === undefined) {
        window.location.href = "../html/login.html"
    }

    layui.use('table', function () {
        var table = layui.table;
        var whereData = {}
        //卡号
        whereData.stockCode = getParam("stockCode");
        //第一个实例
        table.render({
            elem: '#demo'
            , height: 312
            , id: 'testReload'
            , where: whereData
            , headers: {sessionId: getToken()}
            , url: abc() + '/admin/financial/getStockUserCoinCharges' //数据接口
            , page: true //开启分页
            , cols: [[ //表头
                {field: 'id', title: 'id', sort: true, fixed: 'left', align: 'center'}
                , {field: 'swiftNo', title: '流水号', align: 'center'}
                , {field: 'stockUserId', title: '手机用户ID', align: 'center'}
                , {field: 'stockCode', title: 'IC卡号', align: 'center'}
                , {field: 'fee', title: '人民币金额', align: 'center'}
                , {
                    field: 'withdrawStatus', title: '支付状态', templet: function (val) {
                        if (val.withdrawStatus == 1) {
                            return "未支付";
                        }
                        if (val.withdrawStatus == 2) {
                            return "支付成功 ";
                        }
                        if (val.withdrawStatus == 3) {
                            return "支付失败";
                        }
                        if (val.withdrawStatus == 4) {
                            return "处理中";
                        }
                    }, align: 'center'
                }
                , {field: 'createTime', title: '创建时间', align: 'center'}
                , {
                    field: 'isDeleted', title: '删除状态', templet: function (val) {
                        if (val.isDeleted == 0) {
                            return "未删除";
                        }
                        if (val.isDeleted == 1) {
                            return "删除";
                        }
                    }, align: 'center'
                }
                , {field: 'timestamp', title: '修改时间', align: 'center'}
                , {field: 'tranId', title: '三方支付平台的流水号', align: 'center'}
                , {
                    field: 'payType', title: '支付类型', templet: function (val) {
                        if (val.tranId == 1) {
                            return "微信";
                        }
                        if (val.tranId == 2) {
                            return "线下";
                        }else{
                            return "暂无";
                        }
                    }, align: 'center'
                }
                , {field: 'payType', title: '昵称', align: 'center'}
                , {field: 'agentUserId', title: ' 充值代理商ID', align: 'center'}
            ]]
            , request: {
                pageName: 'page' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            ,done: function(res, curr, count){
                if (res.code ===100) {
                    layer.msg("登录失效，请重新登录")
                    window.location.href = "../html/login.html"
                    return;
                }
            }
            , parseData: function (res) { //res 即为原始返回的数据
                if (res.code !== 0) {
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg //解析提示文本
                    };
                } else {
                    return {
                        "code": res.code, //解析接口状态
                        "msg": res.msg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": res.data.list //解析数据列表
                    };
                }

            }
        });

    });

    //搜索
    function sech() {
        var whereData = {};
        whereData.tel = $("#tel").val();
        //表刷新方法
        var table = layui.table;
        table.reload('testReload', {
            url: abc() + '/admin/financial/getMoneyDetails'
            , where: whereData
        });

    }

    //把重置添加一个点击事件点击重置刷新页面
    function chong() {
        window.location.reload();
    }
</script>
